import React, { Component, Fragment } from 'react';
import { formatMessage, FormattedMessage } from 'umi/locale';
import router from 'umi/router';
import {
  Form,
  Input,
  Upload,
  Select,
  Button,
  Rate,
  Row,
  Col,
  message,
  Card,
  Radio,
  Tabs,
} from 'antd';
import { connect } from 'dva';
import styles from './BaseView.less';
import DescriptionList from '@/components/DescriptionList';
import ScrollSelect from '@/components/ScrollSelect';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { REGION_ADDRESS_TYPE } from '@/Constants';
import { stringify } from 'querystring';

const { Description } = DescriptionList;

const FormItem = Form.Item;
const { Option } = Select;
const { TabPane } = Tabs;

@connect(({ base, product, loading }) => ({
  currentProduct: product.currentProduct,
  scopeRegions: base.scopeRegions,
  loading: loading.effects['base/getRegions'],
}))
@Form.create()
class ScopeView extends Component {
  constructor(props) {
    super(props);
    this.state = {
      mode: 'edit',
    };
  }

  componentDidMount() {
    const { dispatch, location, currentProduct } = this.props;
    dispatch({
      type: 'base/getRegions',
      payload: {
        pathParams: {
          schemaId: currentProduct.regionStart,
        },
      },
    }).then(res => {
      if (res.errorCode === 0 && res.data && res.data.length > 0) {
        this.setState({ mode: 'view' });
      }
    });
  }

  render() {
    const { mode } = this.state;
    const { loading, location, currentProduct, children } = this.props;
    let entry = location.query.entry;
    let isAirline = currentProduct.typeCode === 'ST004' && currentProduct.typeCodeSub === 'AIR';
    return (
      <Card bordered={false} loading={loading}>
        {children}
      </Card>
    );
  }
}

export default ScopeView;
